package cn.zhizihua.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan("cn.zhizihua.mapper")
public class MybatisPlusConfig {

    /**
     * 配置分页插件  分页拦截器
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        // 1、创建拦截器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 2、创建分页组件
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
        paginationInnerInterceptor.setMaxLimit(1000L); //最大查询数量
        // 3、添加分页组件
        interceptor.addInnerInterceptor(paginationInnerInterceptor);

        return interceptor;
    }
}
